class ALVO_RUNTIME

inherit AC; ALVO_M; A_CONT_TAG

feature

	base: like Current is
		once
			!!Result.make
		end -- base
		
feature

	push (aa: ALVO) is
		do
			items.push_back(aa)
		end -- push

	pop: ALVO is
		do
			Result := items.back
			items.pop_back
		end

	eval(ae: A_EVAL) is
		local
			--scar, 
			face: STRING
			xx,fnname,fnbody,p: ALVO
			cfnname:STRING
			xint:A_INT
			--xstr:A_STR
		do
			--~ printf("ALVO_runtime::eval --> %s\n", ae->m);
			
			!!face.make (ae.m)
			
			if face.is_equal("print") then
				xx:=pop
				
				--
				if (xx.ac=AC_INTEGER) then
					xint?=xx
					print_int(xint.m)
				else 
					assert(false)
				end
			 elseif face.is_equal( "def") then
				fnname:=pop
				fnbody:=pop
				fns.put(fnname.m, fnbody)
			 else 
				fnname:=pop
				cfnname:=fnname.m

				b:=fns.find(cfnname)
				if not b then 
					assert(135=False);
				else 
					p:=fns.item
					eval(Current, p);
				end
			end
		end -- eval

feature
	c:ALVO_C is do !!Result end
	x:ALVO_X is do !!Result end

feature

--	map<char*,ALVO*,ltstr> fns;
--	typedef map<char*,ALVO*,ltstr>::iterator fns_iter;
--	vector<ALVO*> items;
--	static ALVO_runtime *base;
	
feature
	--
	parent:ALVO_RUNTIME is do end
	--

feature

	items: ITEMS[ALVO]
	
end -- class ALVO_RUNTIME

